package cn.wolfcode.luowowo.controller;

import cn.wolfcode.luowowo.domain.Strategy;
import cn.wolfcode.luowowo.domain.StrategyCatalog;
import cn.wolfcode.luowowo.domain.Travel;
import cn.wolfcode.luowowo.service.*;
import cn.wolfcode.luowowo.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

// 目的地
@RestController
@RequestMapping("destinations")
public class DestinationController {

    @Autowired
    private IRegionService regionService;

    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IStrategyCatalogService strategyCatalogService;

    @Autowired
    private IStrategyService strategyService;

    @Autowired
    private ITravelService travelService;

    // 通过状态查询热门区域 并且要排序(页面上热门目的地)
    @GetMapping("/hotRegion")
    public Object hotRegion(){
        return JsonResult.success(regionService.queryHotRegion());
    }

    // 通过区域id查询目的地
    @GetMapping("/search")
    public Object search(String regionId){
        return JsonResult.success(destinationService.queryDestByRegionIdForApi(regionId));
    }

    // 吐司(热门目的地下的广州跳转页面的吐司)

    @GetMapping("/toasts")
    public Object toasts(String destId){
        return JsonResult.success(destinationService.queryToasts(destId));
    }

    // 目的地下所有攻略分类
    @GetMapping("/catalogs")
    public Object catalogs(String destId){
        List<StrategyCatalog> list = strategyCatalogService.queryCatalogByDestId(destId);
        return JsonResult.success(list);
    }

    // 点击量前三的攻略文章
    @GetMapping("/strategies/viewnumTop3")
    public Object strategiesViewnumTop3(String destId){
        List<Strategy> list = strategyService.queryViewnumTop3(destId);
        return JsonResult.success(list);
    }

    // 查某个目的地下游记点击量前3的文篇
    @GetMapping("/travels/viewnumTop3")
    public Object travelsViewnumTop3(String destId){
        List<Travel> list = travelService.travelsViewnumTop3(destId);
        return JsonResult.success(list);
    }

}
